<template>
    <div class="e-form">
        <BillTop title="报废申请编辑" @cancel="handleClose"></BillTop>
        <div class="tabs warningTabs">
            <el-tabs tab-position="left" v-model="tabsName" @tab-click="onChangeTab">
                <!-- 基本信息 -->
                <el-tab-pane label="基本信息" name="baseInfo" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane label="申请信息" name="planDetail" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane label="附件信息" name="attach" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane label="审核历史" name="auditHistory" :disabled="clickTabFlag"></el-tab-pane>
                <div>
                    <div id="baseInfoCon" class="con">
                        <div class="tabs-title" id="baseInfo">基本信息</div>
                        <div style="width: 100%" class="form">
                            <el-form ref="form" :model="formData.scrapApply" label-width="200px" :rules="rules">
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="申请编号：">
                                            <span>{{ formData.scrapApply.billNo }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="申请日期：" prop="applyDate">
                                            <el-date-picker
                                                v-model="formData.scrapApply.applyDate"
                                                type="date"
                                                placeholder="选择日期"
                                                value-format="yyyy-MM-dd"
                                                :clearable="false"
                                            >
                                            </el-date-picker>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="申请类型：" prop="type">
                                            <el-select v-model="formData.scrapApply.type">
                                                <el-option :value="item.value"  :label="item.label" v-for="item,index in typeList" :key="index" ></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="申请人：">
                                            <span>{{ formData.scrapApply.proposer }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="机构：">
                                            <span>{{ formData.scrapApply.orgName }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="状态：">
                                            <span>{{ statusLable(formData.scrapApply.state) }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="24">
                                        <el-form-item  label="报废处置说明：">
                                            <el-input type="textarea" v-model="formData.scrapApply.info" placeholder="请输入内容"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </el-form>
                        </div>
                    </div>

                    <div id="planDetailCon" class="con">
                        <div class="tabs-title" id="planDetail">申请信息</div>
                        <div class="e-table">
                            <div class="top">
                                <div class="left">
                                    <div>
                                        <el-button  class="btn-greenYellow" @click="addPlanInfo">新增</el-button>
                                        <el-button  class="btn-delete" @click="deletePlanList" v-if="isBatch[0].flag">批量删除</el-button>
                                    </div>
                                    <div class="batchBox" @click="batchOperation('planDetail')">
                                        <img class="batchicon" src="@/assets/piliang.png">
                                        <span class="batchfont">{{isBatch[0].batch}}</span>
                                    </div>
                                </div>
                            </div>
                            <div class="errorMsg" v-if="errorMsg.length>0">
                                <span v-for="item,index in errorMsg" :key="index">
                                    {{item}}
                                </span>
                            </div>
                            <el-table
                                :max-height="$store.state.tableHeight"
                                class="table"
                                ref="planTable"
                                :data="scrapApplyDtlListCopy"
                                border
                                style="width: 100%"
                                @selection-change="planTableSelect"
                                v-sortTable="{ 'tableData': scrapApplyDtlListCopy, '_this': this, 'ref': 'planTable' }"
                            >
                                <el-table-column type="selection" width="55" align="center" v-if="isBatch[0].flag">
                                </el-table-column>
                                <el-table-column  fixed type="index" label="序号" width="80" align="center">
                                </el-table-column>
                                <el-table-column fixed label="操作" width="70">
                                    <template slot-scope="{ row,$index }">
                                        <div class="handle">
                                            <div style=" cursor: pointer;">
                                                <img src="@/assets/btn/delete.png"  @click="handleDelete(row,$index)">
                                            </div>
                                        </div>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="equipmentNo"
                                    label="设备编号"
                                    min-width="200"
                                    show-overflow-tooltip
                                    align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="equipmentName"
                                    label="设备名称"
                                    min-width="200"
                                    show-overflow-tooltip
                                    align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="specificationModel"
                                    label="规格型号"
                                    min-width="200"
                                    show-overflow-tooltip
                                    align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="buyTime"
                                    label="购置日期"
                                    width="150"
                                    align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="originalPrice"
                                    label="设备原值（元）"
                                    width="150"
                                    align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="formerPrice"
                                    label="累计折旧（元）"
                                    width="150"
                                    align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="equipmentValue"
                                    label="设备净值（元）"
                                    width="150"
                                    align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="stipulateTime"
                                    label="规划使用年限"
                                    width="150"
                                    align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="alreadyTime"
                                    label="已使用年限"
                                    width="150"
                                    align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="processMode"
                                    label="处置方式"
                                    width="150"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-select v-model="row.processMode"  @input="curStateChange(row)" @change="selectProcessMode($event,row)">
                                           <el-option :value="item.value"  :label="item.label" v-for="item,index in processModeList" :key="index" ></el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                 <el-table-column
                                    prop="scrapType"
                                    label="报废类型"
                                    width="150"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-select v-model="row.scrapType"  @input="curStateChange(row)">
                                            <el-option :value="item.value"  :label="item.label" v-for="item,index in scrapTypeList" :key="index" ></el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="presentPlace"
                                    label="设备所在地"
                                    width="220"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.presentPlace" clearable  @input="curStateChange(row)"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="evaluateUnit"
                                    label="评估单位"
                                    width="150"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.evaluateUnit" clearable v-if="row.processMode != 0 ||row.processMode == ''" @input="curStateChange(row)"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="evaluatePrice"
                                    label="评估价（元）"
                                    width="150"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.evaluatePrice" clearable v-if="row.processMode != 0 || row.processMode == ''"
                                        @input="curStateChange(row)"
                                        v-enter-float="{
                                            set: row,
                                            key: 'evaluatePrice'
                                        }"></el-input>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>

                    <div id="attachCon" class="con">
                        <div class="tabs-title" id="attach">附件信息</div>
                        <attach-comp :relationId="attachId" bucketName="facilitymanagement" />
                    </div>

                    <div id="auditHistoryCon" class="con">
                        <div class="tabs-title" id="auditHistory">审核历史</div>
                        <div class="e-table">
                            <ComAuditHistoryIndex
                                billType="3011"
                                :tableData.sync="auditHistoryTable"
                                @getAuditHistory="getAuditHistory"
                                ref="AuditHistoryRef"
                            />
                        </div>
                    </div>
                </div>
            </el-tabs>
        </div>
        <div class="buttons">
            <ComExaButtons :auditState="auditState" :state="formData.scrapApply.state" @exas="exas" :founderId="formData.scrapApply.founderId" />
            <el-button size="small" @click="handleClose" v-debounce>取消</el-button>
        </div>
        <div id="seat" :style="{height: seatHeight + 'px'}"></div>
    </div>
</template>

<script>
import { mapState } from 'vuex'
import $ from 'jquery'
import request from '@/api/equip/dailyManagement.js'
import '@/utils/jquery.scrollTo.min'
import AttachComp from '@/components/common/attachIndex'
import ComAuditHistoryIndex from '@/pages/equipment/components/auditHistory/auditHistoryIndex'
import { hideLoading, showLoading } from '@/utils/common'
import { getCurrentUnitInfo, history } from '@/api/equip/dailyManagementAudit.js'
import { exas, saveAll, submitCommit } from '@/pages/equipment/components/auditHistory/equipCom.js'
import { selectScrapApplication, removeRepetition } from '@/api/equip/popupCallback.js'
export default {
    data () {
        return {
            isBatch: [
                {
                    flag: true,
                    batch: '进入批量管理'
                },
            ],
            tabsName: 'baseInfo',
            screenWidth: 0,
            screenHeight: 0,
            lastConHeight: 0,
            clickTabFlag: false, // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            tableData: [],
            formData: {
                //基础信息
                'scrapApply': {
                    'applyDate': '',
                    'billId': '',
                    'billNo': '',
                    'founderId': '',
                    'founderName': '',
                    'info': '',
                    'nullifyCreated': '',
                    'nullifyCreator': '',
                    'nullifyCreatorId': '',
                    'nullifyDescription': '',
                    'nullifyReason': '',
                    'orgId': '',
                    'orgName': '',
                    'proposer': '',
                    'proposerId': '',
                    'state': 0,
                    'type': '',
                    'workId': ''
                },
            },
            rules: {
                applyDate: [
                    { required: true, message: '请选择申请日期', trigger: 'change' },
                ],
                type: [
                    { required: true, message: '请选择申请类型', trigger: 'change'  },
                ],
            },
            billid: this.$route.query.billid,
            scrapApplyDtlList: [], //申请信息表格
            scrapApplyDtlListCopy: [],
            planSelect: [], //申请信息选择项
            auditHistoryTable: [], //审核历史
            workIndex: 0,
            errorList: [], //控制导航栏感叹号的显示
            errorMsg: [], //计划明细错误显示
            isErrorMsg: true, //是否提醒错误信息
            currentRow: {},
            auditState: {}, //流程按钮显示状态
            auditParams: {
                'billId': this.$route.query.billid,
                'billType': 3011,
                'freeNextUnitIndex': null,
                'freeNextUser': '',
                'isPass': true,
                'isShareInAudit': true,
                'opinion': '',
                'orgId': '',
                'orgName': '',
                'userId': '',
                'workId': ''
            },
            nullifyParams: { //作废
                'billId': this.$route.query.billid,
                'billType': 3011,
                'nullifyCreated': '',
                'nullifyCreator': '',
                'nullifyCreatorId': '',
                'nullifyDescription': '',
                'nullifyReason': ''
            },
            isShowUnit: true, //默认显示公开单位
        }
    },
    computed: {
        ...mapState({
            userInfo: state => state.userInfo,
            typeList: state => state.equip.equipData.typeList, //申请类型
            scrapTypeList: state => state.equip.equipData.scrapTypeList, //报废类型
            processModeList: state => state.equip.equipData.processModeList, //处置方式
        }),
        statusLable () {
            return param=> {
                const state =  this.$store.state.equip.equipData.state
                const obj = state.find(x=>x.value === param)
                return obj.label
            }
        },
        //当前单据状态
        state () {
            return this.formData.scrapApply.state
        },
        attachId () {
            return this.$route.query.billid
        },
        // 填补底部空白，以使高度够滚动
        seatHeight () {
            return this.screenHeight - 72 - this.lastConHeight
        }
    },
    components: {
        AttachComp,
        ComAuditHistoryIndex,
    },
    watch: {
        //给错误标签加上提醒
        errorList: newData=>{
            const tabs = document.querySelectorAll('.el-tabs__item')
            tabs.forEach(DOM=>{
                const { childNodes } = DOM
                if(childNodes.length > 1) {
                    DOM.removeChild(childNodes[1])
                }
            })
            newData.forEach(item=>{
                const itemDom = document.querySelector(`#tab-${item}`)
                var element = document.createElement('i')
                element.className = 'el-icon-warning-outline warning'
                itemDom.appendChild(element)
            })
        },
    },
    created () {
        this.userId = localStorage.getItem('userId')
        this.getDicValue()
    },
    mounted () {
        this.init()
        // 获取最后一个内容区域的高度，计算底部空白
        this.getLastConHeight()

        // 保存所有tabName
        const arr = ['baseInfo', 'planDetail', 'attach', 'auditHistory']
        this.tabArr = arr
        let $idsTop = []
        window.addEventListener('scroll', () => {
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            if (this.clickTabFlag) {
                return
            }

            if (!$idsTop[$idsTop.length - 1]) {
                $idsTop = arr.map(item => {
                    console.log('item', item)
                    const itemTop = document.getElementById(item).offsetTop
                    return itemTop
                })
            }
            const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
            // 倒序查找
            let curLocal = 0
            for (let len = $idsTop.length, i = len - 1; i >= 0; i--) {
                let item = $idsTop[i]
                if ((scrollTop + 1) >= item) {
                    curLocal = i
                    break
                }
            }
            // 设置对应tabName
            this.tabsName = arr[curLocal]
        })

        this.screenWidth = document.documentElement.clientWidth - this.topHeight
        this.screenHeight = document.documentElement.clientHeight - this.topHeight
        window.addEventListener('resize', () => {
            this.screenWidth = document.documentElement.clientWidth - this.topHeight
            this.screenHeight = document.documentElement.clientHeight - this.topHeight
            $idsTop = arr.map(item => {
                const itemTop = document.getElementById(item).offsetTop
                return itemTop
            })
        })
        this.scorllDtl()
    },
    methods: {
        //获取当前使用的字典
        getDicValue () {
            this.$store.dispatch('equip/setProcessModeList')//更新处置方式
        },
        //是否进入批量操作
        batchOperation (name) {
            switch(name) {
            case 'planDetail':
                this.isBatch[0].flag = !this.isBatch[0].flag
                if(this.isBatch[0].flag) {
                    this.isBatch[0].batch = '退出批量管理'
                    this.$refs.planTable.clearSelection()
                }else{
                    this.isBatch[0].batch = '进入批量管理'
                }
                break
            }
        },
        //跳转到明细
        scorllDtl () {
            if(this.$route.query.name) {
                setTimeout(() => {
                    //因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                    let obj = {
                        name: this.$route.query.name
                    }
                    this.tabsName = this.$route.query.name
                    this.onChangeTab(obj)
                }, 200)
            }
        },
        //初始化数据
        init () {
            showLoading()
            Promise.all([
                this.getInfo(),
                this.getPlanList(),
                this.getCurrentUnitInfo(),
                this.getAuditHistory(),
            ]).finally(() => {
                hideLoading()
            })
        },
        getInfo () {
            const params = {
                billId: this.billid,
            }
            request.scrapApplicationBaseInfo(params).then(res=>{
                this.formData.scrapApply = res
            })
        },
        getPlanList () {
            const params = {
                id: this.billid,
            }
            request.scrapApplicationPlanInfo(params).then(res=>{
                this.scrapApplyDtlListCopy = []
                res.scrapApplyDtlList.map(item=>{
                    this.scrapApplyDtlListCopy.push(item)
                })
                this.scrapApplyDtlList = res.scrapApplyDtlList
            })
        },
        //获取状态按钮
        getCurrentUnitInfo () {
            getCurrentUnitInfo(this.auditParams).then(res => {
                this.auditState = res
            })
        },
        //刷新历史审核列表
        getAuditHistory () {
            history(this.auditParams).then(res=>{
                this.auditHistoryTable = res
            })
        },
        getNowDate () {
            this.$set(
                this.formData,
                'applyTime',
                new Date()
                    .toLocaleDateString()
                    .replace(new RegExp('/', 'g'), '-')
            )
        },
        //================申请信息======================
        //处置方式切换
        selectProcessMode ($event, row) {
            row.evaluatePrice = null
            row.evaluateUnit = ''
        },
        //判断当前状态是否已修改
        curStateChange (row) {
            this.currentRow = row
            if (row.scrapApplyDtlId) {
                this.currentRow.changeType = 2
            }
        },
        //申请信息新增
        addPlanInfo () {
            let ids = []
            let type = {
                'type': this.formData.scrapApply.type,
                'states': []
            }
            ids = this.scrapApplyDtlListCopy.map(x=>x.accountId)
            selectScrapApplication(ids, type).then(res=>{
                res.forEach(item=>{
                    let obj = {
                        'accountId': item.billId,
                        'alreadyTime': item.serviceLife,
                        'billId': this.billid,
                        'billNo': '',
                        'buyTime': item.purchaseDate,
                        'changeType': 1,
                        'equipmentId': item.equipmentId,
                        'equipmentName': item.equipmentName,
                        'equipmentNo': item.equipmentNo,
                        'equipmentValue': item.netWorth,
                        'evaluatePrice': null,
                        'evaluateUnit': '',
                        'formerPrice': item.depreciationCount,
                        'originalPrice': item.purchasePrice,
                        'presentPlace': '',
                        'processMode': '',
                        'scrapApplyDtlId': '',
                        'scrapType': '',
                        'specificationModel': item.specificationModel,
                        'stipulateTime': item.stipulatedServiceLife,
                        'categoryName': item.categoryName, //分类名称
                        'unit': item.unit, //计量单位
                    }
                    this.scrapApplyDtlListCopy.push(obj)
                    this.scrapApplyDtlList.push(obj)
                })
                this.scrapApplyDtlListCopy = removeRepetition({
                    'arr': this.scrapApplyDtlListCopy,
                    'id': 'accountId'
                })
                this.scrapApplyDtlList = removeRepetition({
                    'arr': this.scrapApplyDtlList,
                    'id': 'accountId'
                })
            })

        },
        //获取申请信息表格的选择项
        planTableSelect (selection) {
            this.planSelect = selection
        },
        //单个明细表格删除
        handleDelete (row, $index) {
            this.clientPop('info', this.oneDeleteErr, ()=>{
                let length = this.errorMsg.length
                this.scrapApplyDtlListCopy.splice($index, 1)
                if(row.scrapApplyDtlId) {
                    this.$set(this.scrapApplyDtlList[$index], 'changeType', -1)
                }else{
                    this.scrapApplyDtlList.splice($index, 1)
                }
                if (length > 0 ) {
                    this.verifyTable()
                }
            })
        },
        //删除明细列表
        deletePlanList () {
            const length = this.planSelect.length
            if(length === 0) {
                this.clientPop(
                    'info',
                    '你还未选择数据,请选择!',
                )
            }else{
                this.clientPop(
                    'info',
                    this.moreDeleteErr(length),
                    this.delete
                )
            }
        },
        delete () {
            this.planSelect.filter(row=>{
                this.scrapApplyDtlListCopy.map((x, index)=>{
                    if(row == x ) {
                        this.scrapApplyDtlListCopy.splice(index, 1)
                    }
                })
                if(row.scrapApplyDtlId) {
                    const index = this.scrapApplyDtlList.findIndex(item=>{
                        return item.scrapApplyDtlId == row.scrapApplyDtlId
                    })
                    this.$set(this.scrapApplyDtlList[index], 'changeType', -1)
                }else{
                    this.scrapApplyDtlList.map((x, index)=>{
                        if(row == x ) {
                            this.scrapApplyDtlList.splice(index, 1)
                        }
                    })
                }
                if (length > 0 ) {
                    this.verifyTable()
                }
                this.$refs.planTable.clearSelection()
            })
        },
        //计划明细非空验证
        verifyTable () {
            return  new Promise((resolve, reject)=>{
                this.errorMsg = []
                this.scrapApplyDtlListCopy.forEach((item, index)=>{
                    if(item.changeType !== -1) {
                        if(item.processMode === null || item.processMode === '') {
                            let str = `请选择第 ${index + 1} 行的（处置方式）`
                            this.errorMsg.push(str)
                        }
                        if(item.scrapType === null || item.scrapType === '') {
                            let str = `请选择第 ${index + 1} 行的（报废类型）`
                            this.errorMsg.push(str)
                        }
                        if(item.presentPlace === null || item.presentPlace === '') {
                            let str = `请填写第 ${index + 1} 行的（设备当前所在地）`
                            this.errorMsg.push(str)
                        }
                    }
                })
                this.errorMsg.length > 0 ? reject() : resolve()
            })
        },
        //=======保存、提交========
        //更新基础信息
        updateBaseInfo () {
            return new Promise((resolve, reject)=>{
                this.$refs.form.validate(valid => {
                    if(valid) {
                        request.scrapApplicationUpdate(this.formData).then(()=>{
                            resolve()
                        }).catch(err=>{
                            reject(err)
                            this.setError('baseInfo')
                            this.scorllError()
                        })
                    }else{
                        reject()
                        this.setError('baseInfo')
                        this.scorllError()
                        return false
                    }
                })
            })
        },
        //更新计划明细
        updateDetailInfo () {
            return new Promise((resolve, reject)=>{
                this.verifyTable().then(()=>{
                    request.scrapApplicationDtlUpdate(this.scrapApplyDtlList).then(()=>{
                        resolve()
                    }).catch(err=>{
                        reject(err)
                        this.setError('planDetail')
                        this.scorllError()
                    })
                }).catch(err=>{
                    this.setError('planDetail')
                    reject(err)
                    this.scorllError()
                })
            })
        },
        //保存全部数据
        saveAll () {
            const requestFn = ()=>{
                return [
                    this.updateBaseInfo(),
                    this.updateDetailInfo()
                ]
            }
            saveAll(this, requestFn)
        },
        //保存并提交
        submitCommit () {
            if(this.scrapApplyDtlListCopy.length === 0) {
                let str = '计划明细不能空！'
                this.errorMsg.push(str)
                this.setError('planDetail')
                this.scorllError()
                return
            }
            const requestFn = ()=>{
                return [
                    this.updateBaseInfo(),
                    this.updateDetailInfo()
                ]
            }
            submitCommit(this, requestFn, 2)
        },
        //删除
        deleteBills () {
            this.clientPop('info', this.oneDeleteErr, ()=>{
                request.scrapApplicationDelete({ scrapApplyIdList: this.billid }).then(()=>{
                    this.clientPop('suc', '删除成功', this.handleClose)
                })
            })
        },
        // 审核相关操作
        async exas (arg) {
            const requestFn = ()=>{
                return []
            }
            exas(arg, this, requestFn, 2)
        },
        //取消
        handleClose () {
            this.$router.replace('/scrapApplicationList')
        },
        // 获取最后一个内容区域的高度，计算底部空白
        getLastConHeight () {
            let si = setInterval(() => {
                // 因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                if (document.getElementById('recodesCon')) {
                    const lastConHeight = document.getElementById('recodesCon').offsetHeight
                    console.log('lastConHeight: ', lastConHeight)
                    this.lastConHeight = lastConHeight
                    clearInterval(si)
                    si = null
                }
            }, 100)
        },
        onChangeTab (e) {
            const height  = $('#' + e.name).offset().top
            $.scrollTo(height - this.topHeight, 500)
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            this.clickTabFlag = true
            // 动画结束后，恢复状态
            setTimeout(() => {
                this.clickTabFlag = false
            }, 600)
        },
        //设置错误标签
        setError (name) {
            if(!this.errorList.find(x=>x === name)) {
                this.errorList.push(name)
            }
        },
        //跳转到第一个错误标签
        scorllError () {
            let num = this.tabArr.length
            this.errorList.forEach(item=>{
                let index = this.tabArr.findIndex(x=>x === item)
                num = index < num ? index : num
            })
            const obj = { name: this.tabArr[num] }
            this.tabsName = this.tabArr[num]
            this.onChangeTab(obj)
        },
    }
}
</script>

<style lang="scss" scoped>
.form {
    margin-top: 10px;
}

.e-table {
    background: #fff;
}
</style>
